<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MvcCms.Web.ViewModels.BackOfficeModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    MvcCms -
    <%=ViewData["PageTitle"]%>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div class="contentpage-outerdiv">
    <h2>
        <%=ViewData["PageTitle"]%></h2>
    <table cellpadding="5" cellspacing="5">
        <tr>
            <td>
                <table border="0" cellpadding="0" cellspacing="0" class="data-table">
                <tr><th>Title</th><th>Target Div or element</th><th></th></tr>
                    <%
                        foreach (var widget in Model._Widgets)
                        {%>
                    <tr>
                        <td>
                            <%=Html.ActionLink(widget.Title, "editwidget", new { id = widget.WidgetID})%>
                        </td>
                        <td>
                            <%=Html.Encode(widget.TargetDiv)%>
                        </td>                                                
                        <td>    
                        <a href="javascript:void(0)" onclick="DeleteWidget(<%=widget.WidgetID %>)">Delete</a>
                        </td>
                    </tr>
                    <%}    
                    %>
                </table>
            </td>
        </tr>
    </table>
    <p>
        <%= Html.ActionLink("Create New Widget", "CreateWidget")%>
    </p>
</div>     
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HeaderContent" runat="server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="ScriptContent" runat="server">
<script type="text/javascript" >
    function DeleteWidget(widgetid) {
        if (confirm("Are you sure you want to delete this widget?")) {
            window.location.href = "managewidgets/" + widgetid;
        }
    }
</script>
</asp:Content>
